clear all
pause off

cd "/Users/jvogel/Dropbox/JvogelPrivateWork/Cannonical_Model_MW/Replication/Data/"

********************************************************************************
/* 
Use Cengiz, Dube, Lindner, Zipperer (2019)
Quarterly mean, min, max observations for each state btw 1974q2 - 2017q1
  To construct biannual max (what I use):
	1) take max of the maxes w/in each quarter
	2) take max of this across quarters in the year-bian pair
*/
********************************************************************************

use "Input/VZ_mw_state_quarterly_new", clear

* create year and quarter variables
rename quarterly_date qd
gen year = year(dofq(qd))
gen qtr = quarter(dofq(qd))
gen bian=.
replace bian=1 if qtr<=2 & bian==.
replace bian=2 if qtr<=4 & bian==.
drop qtr
* check that state value is weakly greater than federal within year-quarter
gen diff = max_mw - max_fed_mw
assert diff>-0.00001
* use the max of maxes across quarters within bian
bys statefips year bian: egen mw=max(max_mw)
* keep year, bian, mw, and state; then drop duplicates
keep year bian statefips mw
duplicates drop
* set mw to two decimals 
replace mw=round(mw,0.01)
* keep right years
drop if year==2017

save "Output/state_yb_combo.dta", replace
